import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

import '../../common/channel/action.dart';
import '../../common/utils/toast.dart';

class ContactScreen extends StatefulWidget {
  const ContactScreen({super.key});

  @override
  State<ContactScreen> createState() => _ContactScreemnState();
}

class _ContactScreemnState extends State<ContactScreen> {
  final subjectController = TextEditingController();
  final bodyController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: GestureDetector(
          onTap: () {
            context.pop();
          },
          child: const Padding(
            padding: EdgeInsets.all(16),
            child: Icon(Icons.arrow_back_ios, color: Colors.white),
          ),
        ),
        title: const Text('Contact Us', style: TextStyle(fontSize: 18)),
      ),
      body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.all(10),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              const Text(
                "In our app to contact page user see this app use and sharing any kind of information to directly contact us page tp visit and to write name and type text any details you know and directly contact in app developer to type message and submit.",
                style: TextStyle(
                    fontSize: 12, color: Colors.white, fontFamily: 'medium'),
              ),
              const SizedBox(height: 10),
              TextField(
                controller: subjectController,
                style: const TextStyle(fontSize: 13, color: Colors.white),
                cursorColor: const Color(0xff4744d3),
                textInputAction: TextInputAction.done,
                decoration: InputDecoration(
                  hintText: "Enter Subject",
                  hintStyle: TextStyle(color: Colors.white.withOpacity(0.5)),
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(8),
                    borderSide: const BorderSide(color: Color(0xff4744d3)),
                  ),
                  enabledBorder: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(8),
                    borderSide: const BorderSide(color: Color(0xff4744d3)),
                  ),
                  focusedBorder: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(8),
                    borderSide: const BorderSide(color: Color(0xff4744d3)),
                  ),
                  filled: true,
                  fillColor: Colors.white.withOpacity(0.1),
                  contentPadding: const EdgeInsets.symmetric(horizontal: 10),
                ),
              ),
              const SizedBox(height: 16),
              TextField(
                controller: bodyController,
                style: const TextStyle(fontSize: 13, color: Colors.white),
                cursorColor: const Color(0xff4744d3),
                maxLines: 3,
                textInputAction: TextInputAction.done,
                decoration: InputDecoration(
                  hintText: "Type Message Here..",
                  hintStyle: TextStyle(color: Colors.white.withOpacity(0.5)),
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(8),
                    borderSide: const BorderSide(color: Color(0xff4744d3)),
                  ),
                  enabledBorder: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(8),
                    borderSide: const BorderSide(color: Color(0xff4744d3)),
                  ),
                  focusedBorder: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(8),
                    borderSide: const BorderSide(color: Color(0xff4744d3)),
                  ),
                  filled: true,
                  fillColor: Colors.white.withOpacity(0.1),
                  contentPadding: const EdgeInsets.all(10),
                ),
              ),
              const SizedBox(height: 16),
              Row(
                children: [
                  Expanded(
                    child: ElevatedButton(
                      onPressed: () async {
                        // Handle Submit
                        final subject = subjectController.text;
                        if (subject.isEmpty) {
                          showToast('Please enter subject');
                          return;
                        }
                        final body = bodyController.text;
                        if (body.isEmpty) {
                          showToast('Please enter message');
                          return;
                        }
                        action.mailto(subject, body);
                        context.pop();
                      },
                      style: ElevatedButton.styleFrom(
                        backgroundColor: const Color(0xff4744d3),
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(8),
                        ),
                      ),
                      child: const Text(
                        "Submit",
                        style: TextStyle(fontSize: 13, color: Colors.white),
                      ),
                    ),
                  ),
                  const SizedBox(width: 16),
                  Expanded(
                    child: ElevatedButton(
                      onPressed: () {
                        // Handle Clear
                      },
                      style: ElevatedButton.styleFrom(
                        backgroundColor: const Color(0xff4744d3),
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(8),
                        ),
                      ),
                      child: const Text(
                        "Clear",
                        style: TextStyle(fontSize: 13, color: Colors.white),
                      ),
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}
